/*
 * Copyright 2019 Patrik Karlström.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package se.trixon.almond.util.swing.dialogs;

import java.util.ArrayList;
import javax.swing.DefaultComboBoxModel;
import se.trixon.almond.util.Dict;

/**
 *
 * @author Patrik Karlström
 */
public class TimeZonePanel extends javax.swing.JPanel {

    /**
     * Creates new form TimeZonePanel
     */
    public TimeZonePanel() {
        initComponents();

        ArrayList<String> timeZones = new ArrayList<>();
        for (int i = -14; i < 14 - 1; i++) {
            if (i == 0) {
                timeZones.add("UTC");
            } else {
                timeZones.add(String.format("UTC%+d", i));
            }
        }
        tzCustomComboBox.setModel(new DefaultComboBoxModel<>(timeZones.toArray(new String[0])));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tzButtonGroup = new javax.swing.ButtonGroup();
        tzSystemRadioButton = new javax.swing.JRadioButton();
        tzCustomRadioButton = new javax.swing.JRadioButton();
        tzCustomComboBox = new javax.swing.JComboBox<>();

        tzButtonGroup.add(tzSystemRadioButton);
        tzSystemRadioButton.setSelected(true);
        tzSystemRadioButton.setText(Dict.SYSTEM_TIME_ZONE.toString());

        tzButtonGroup.add(tzCustomRadioButton);
        tzCustomRadioButton.setText(Dict.CUSTOM_TIME_ZONE.toString());

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tzCustomRadioButton)
                    .addComponent(tzSystemRadioButton)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(tzCustomComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(273, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tzSystemRadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tzCustomRadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tzCustomComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(201, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup tzButtonGroup;
    private javax.swing.JComboBox<String> tzCustomComboBox;
    private javax.swing.JRadioButton tzCustomRadioButton;
    private javax.swing.JRadioButton tzSystemRadioButton;
    // End of variables declaration//GEN-END:variables
}
